package Servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAO.DBCon;

/**
 * Servlet implementation class EBIChangeDel
 */
@WebServlet("/EBIChangeDel")
public class EBIChangeDel extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EBIChangeDel() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String workID = request.getParameter("workID1");
		String sql,sql1,sql2;
		
		DBCon dbCon = new DBCon();
		Connection connection = dbCon.getConnection();
		try {
			sql1 = "delete from eeit91 where workID=\""+workID+"\"";
			sql2 = "delete from emst91 where workID=\""+workID+"\"";
			
			PreparedStatement stmt = connection.prepareStatement(sql1);
			stmt.executeUpdate();
			PreparedStatement stmt1 = connection.prepareStatement(sql2);
			stmt1.executeUpdate();
			
			sql = "delete from ebit91 where  workID=\""+workID+"\"";
			PreparedStatement stmt2 = connection.prepareStatement(sql);
			stmt2.executeUpdate();
			
			stmt.close();
			stmt1.close();
			stmt2.close();
			connection.close();
			
			response.setHeader("refresh", "1;url=EBISearch.jsp");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
